using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.Odbc;
using System.Data;

public partial class _Default : System.Web.UI.Page 
{
    void oleTest()
    {
        /*OleDbConnection con = null;
        try
        {
            string conString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
                           @"DataSource=D:\training\project\web\app\scrum\db\scrum.mdb";
            con = new OleDbConnection(conString);
            con.Open();
            string strSql = "select * from product";
            OleDbDataAdapter dAdapter = new OleDbDataAdapter(strSql, con);
            DataSet dSet = new DataSet();
            dAdapter.Fill(dSet, "PersonTable");
            this.Response.Write(dSet.ToString());
        }
        catch (Exception ex)
        {
            this.Response.Write("Error in connection : " + ex.Message);
            if (con != null)
            {
                con.Close();
            }
        }*/
    }
    void odbcTest()
    {
        OdbcConnection con = null;
        try
        {
            con = new OdbcConnection("DSN=scrum");
            con.Open();
            OdbcCommand cmd = con.CreateCommand();
            cmd.CommandText = "select * from product";
            OdbcDataReader reader = cmd.ExecuteReader();
            int fCount = reader.FieldCount;
            while (reader.Read())
            {
                for (int i = 0; i < fCount; i++)
                {
                    String fName = reader.GetName(i);
                    object col = reader.GetValue(i);
                    this.Response.Write(fName + ":" + col + "<br>");
                }
            }
            reader.Close();
            cmd.CommandText = "update [product] set [Desc]='hjkj'";
            int num = cmd.ExecuteNonQuery();
            //cmd.CommandText = "insert into product" + "(ID__c, Name__c)"+ " values(6, 'test')";
            //int num = cmd.ExecuteNonQuery();
            this.Response.Write(num + ": rows affected<br>");
        }
        catch (Exception ex)
        {
            this.Response.Write("Error in connection : " + ex.Message);
            if (con != null)
            {
                con.Close();
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //oleTest();
        odbcTest();
    }
}
